import {Router, hashHistory, Link} from 'react-router';
import Home from '../pages/home/PageHome';
import defaultRouter from '../pages/default';
import xmzxRouter from '../pages/xmzx';
import fgfcRouter from '../pages/fgfc';
import xmmxRouter from '../pages/xmmx';
import xytxRouter from '../pages/xytx';
import grxxRouter from '../pages/grxx';
import ycjkRouter from '../pages/ycjk';
import ycgdRouter from '../pages/ycgd';
import searchRouter from '../pages/search';
import errorRouter from '../pages/error';
import xxlsRouter from '../pages/xxls';
import Map from '../pages/amap/PageAMap.jsx';
import Layout, {Left, Right} from 'uxcore-layout';


// Define webpack publicPath at runtime
__webpack_public_path__ = ((s) => (
  s[s.length - 1].src.replace(/\/[^\/]+$/, '/')
))(document.getElementsByTagName('script'));


// `ReactRouter`文档请看  https://github.com/ReactTraining/react-router/tree/v2.8.1
const App = ({children, location, routes}) => (

  <div>
    <Map location={location} children={children} routes={routes} />
  </div>
);

const rootRoute = {
  childRoutes: [{
    path: '/',
    component: App,
    // 这里可以设置首页跳转的地址
    indexRoute: {onEnter: (nextState, replace) => replace('/default')},
    childRoutes: [
      // 新建页面时，请注意更新此处的路由
      defaultRouter,
      xmzxRouter,
      fgfcRouter,
      xmmxRouter,
      xytxRouter,
      grxxRouter,
      ycjkRouter,
      ycgdRouter,
      xxlsRouter,
      searchRouter
    ],
  }, {errorRouter}],
};

export default {
  history: hashHistory,
  Routes: (<Router history={hashHistory} routes={rootRoute}/>),
};
